package org.example.myportfolio.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.example.myportfolio.dao.mapper.UserMapper;
import org.example.myportfolio.dao.repository.UserRepository;
import org.example.myportfolio.pojo.po.UserPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Slf4j
@Repository("userRepository") // bean name
public class UserRepositoryImpl implements UserRepository {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserPO selectUserByUsername(String username) {
        QueryWrapper<UserPO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", username);
        UserPO userPO = userMapper.selectOne(queryWrapper);
        log.info("userPO: {}", userPO);
        return userPO;
    }
}
